package com.binyouwei.designpatterns.behavior.iterator;


import java.util.ArrayList;
import java.util.List;

/**
 * @author 宾有为
 * Created on 2024/7/15 19:00
 * Social homepage: https://blog.csdn.net/baidu_41616022
 * @desc 迭代器模式 - 具体的集合实现
 **/
public class IteratorConcreteCollection implements IteratorCollection {
    private List<Object> items = new ArrayList<>();

    @Override
    public Iterator createIterator() {
        return new IteratorConcreteIterator(this);
    }

    public void addItem(Object item) {
        items.add(item);
    }

    public int size() {
        return items.size();
    }

    public Object getItem(int index) {
        return items.get(index);
    }
}
